
#include "GeometryManager.hpp"
#include "GeometryData.hpp"

namespace NSExchange {

	GeometryManager* GeometryManager::m_ins = nullptr;

	void GeometryManager::Initialize() {

	}

	void GeometryManager::Finalize() {

	}

	int GeometryManager::addGeometryData(GeometryData* geom) {
		int index = m_geoms.count();
		if (!m_geoms.values().contains(geom) && geom) {
			m_geoms.insert(index, geom);
		}

		return index + 1;
	}

	int GeometryManager::removeGeometryData(int index) {
		if (m_geoms.contains(index)) {
			GeometryData* geom = m_geoms.value(index);
			m_geoms.remove(index);
			if (geom) {
				delete geom;
			}
		}

		return m_geoms.count();
	}

	GeometryData* GeometryManager::getGeometry(int index) {
		if (m_geoms.contains(index)) {
			return m_geoms.value(index);
		}

		return nullptr;
	}

	GeometryData* GeometryManager::getGeometryLast() {
		if (m_geoms.count() > 0) {
			return m_geoms.last();
		}

		return nullptr;
	}


}

